#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
    int missingNumber(vector<int>& nums)
    {
        int x = 0;
        int y = 0;
        int ret = 0;
        for (auto e : nums)
        {
            x ^= e;
        }
        for (int i = 0; i <= nums.size(); i++)
        {
            y ^= i;
        }
        return ret = x ^ y;
    }
};

int main()
{
    Solution sol;
    vector<int> nums;
    nums.push_back(9);
    nums.push_back(6);
    nums.push_back(4);
    nums.push_back(2);
    nums.push_back(3);
    nums.push_back(5);
    nums.push_back(7);
    nums.push_back(0);
    nums.push_back(1);

    int ret = sol.missingNumber(nums);

    cout << ret << endl;
    return 0;
}